//
//  CinemaSeatInfo.m
//  EasyToo
//
//  Created by 郑 哲 on 9/6/13.
//
//

#import "CinemaSeatInfo.h"

@implementation CinemaSeatInfo

- (id)initWithDictionary:(NSDictionary *)jsonDictionary
{
    self = [self init];
    if (self) {
        NSDictionary *dict = GetDictionaryDictionary(jsonDictionary, @"SeatList");
        
        self.cinemaId = GetDictionaryStringDefaultNil(dict, @"cinemaId");
        self.hallId = GetDictionaryStringDefaultNil(dict, @"hallId");
        
        //座位号
        NSArray *seatJsonArray = GetDictionaryArrayDefaultNil(dict, @"Seat");
        if (seatJsonArray)
        {
            self.SeatList = [[NSMutableArray alloc] init];
            for (int i = 0; i < [seatJsonArray count]; i++)
            {
                NSDictionary *showDict = [seatJsonArray objectAtIndex:i];
                
                SeatInfo *seatInfo = [[SeatInfo alloc] initWithDictionary:showDict];
                
                [self.SeatList addObject:seatInfo];
            }
        }
        
        //已选座位号
        NSDictionary *useddict = GetDictionaryDictionary(jsonDictionary, @"UsedSeat");
        NSArray *usedSeatJsonArray = GetDictionaryArrayDefaultNil(useddict, @"UsedSeat");
        if (usedSeatJsonArray)
        {
            self.UsedSeatList = [[NSMutableArray alloc] init];
            for (int i = 0; i < [usedSeatJsonArray count]; i++)
            {
                NSDictionary *showDict = [usedSeatJsonArray objectAtIndex:i];
                
                UsedSeatInfo *usedseatInfo = [[UsedSeatInfo alloc] initWithDictionary:showDict];
                
                [self.UsedSeatList addObject:usedseatInfo];
            }
        }
        
    }
    return self;
}
@end

@implementation SeatInfo

- (id)initWithDictionary:(NSDictionary *)jsonDictionary
{
    self = [self init];
    if (self) {
        self.seatId = GetDictionaryStringDefaultNil(jsonDictionary, @"seatId");
        self.sectionId = GetDictionaryStringDefaultNil(jsonDictionary, @"sectionId");
        self.rowId = GetDictionaryStringDefaultNil(jsonDictionary, @"rowId");
        self.rowNum = GetDictionaryStringDefaultNil(jsonDictionary, @"rowNum");
        self.columnId = GetDictionaryStringDefaultNil(jsonDictionary, @"columnId");
        self.columnNum = GetDictionaryStringDefaultNil(jsonDictionary, @"columnNum");
        self.damagedFlag = GetDictionaryStringDefaultNil(jsonDictionary, @"damagedFlag");
        self.loveIndex = GetDictionaryStringDefaultNil(jsonDictionary, @"loveIndex");
    }
    return self;
}

@end


@implementation UsedSeatInfo

- (id)initWithDictionary:(NSDictionary *)jsonDictionary
{
    self = [self init];
    if (self) {
        self.rowId = GetDictionaryStringDefaultNil(jsonDictionary, @"rowId");
        self.columnId = GetDictionaryStringDefaultNil(jsonDictionary, @"columnId");
    }
    return self;
}

@end

